import java.util.Scanner;

public class demo3 {
    public static String trans1(int num, int radix)
    {
        if(radix == 2)
            return Integer.toBinaryString(num);
        else if(radix == 8)
            return Integer.toOctalString(num);
        else if(radix == 16)
            return Integer.toHexString(num);

        return null;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int s = scanner.nextInt();
        int ra=scanner.nextInt();
        System.out.println(trans1(s,ra));
    }
}
